﻿<script runat="server" language="C#">
	protected void Page_Load(Object sender, EventArgs e) {
		// Set the page's content type.	
		Page.Response.ContentType = "text/css";
		// Clear all response headers.
		Page.Response.Clear();
		// Buffer response so that page is sent after processing is complete.
		Response.BufferOutput = true;
		// Write data to the page.
		Page.Response.Write(getData());
		// Send the output to the client.
		Page.Response.Flush();
		// Check whether the browser remains connected to the server.
		if(!Page.Response.IsClientConnected) {
			// If connected, then do something here.
		} else {
			// If the browser is not connected stop all response processing.
			Page.Response.End();
		}
	}
	/// <summary>Get data from database for Page.Response.Write.</summary>
    protected String getData() {
		// Get id from query string. If invalid, then return an empty string.
		int qsId = System.Convert.ToInt32(Request.QueryString["id"]);
		if(qsId <= 0) {return String.Empty;}
		
		// Get a row from database.
		ent.ServiceContents s1 = new ent.ServiceContents();
		System.Data.DataRow dr1 = s1.getContent(qsId);
		int qsIdContentType = (int)dr1[ent.TableContents.TBL__contents__content_type];

		// Get content from row. If data is not the type, then return an empty string.
		switch(qsIdContentType) {
			case (int)ent.TableLists.enumContentType.Style:
				return HttpUtility.HtmlDecode((String)dr1[ent.TableContents.TBL__contents__content_body]);
			default:
				return String.Empty;
		}
	}
</script>